﻿import QtQuick 2.0
import "../components"
import QtCharts 2.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
Rectangle {
    width: parent.width
    height: parent.height
    property string xh: ""
    property string mc: ""
    property string fbmc: ""
    property string dbmc: ""
    property string zbmc: ""
    property string chmc: ""
    property int pbflag: 3
    Connections{  // qmlre
        target: CExeConfig
        onMaskingInformation:{
            if(value[0]==="1"&&value[1]==="0"){
                pbflag=1
            }else if(value[0]==="0"&&value[1]==="1"){
                pbflag=2
            }else{
                pbflag=3
            }
        }
    }
    signal infochange(int col,string info)


    signal bt3()

    onVisibleChanged: {
        refreshComboText()
    }

    Connections{
        target: exConfig
        onRefreshCombo:{
            var value = CExeConfig.getMaskingInformation()
            if(value[0]==="1"&&value[1]==="0"){
                pbflag=1
            }else if(value[0]==="0"&&value[1]==="1"){
                pbflag=2
            }else{
                pbflag=3
            }
            refreshComboText()
        }
    }


    function refreshComboText(){
        cb1.setText(fbmc)
        cb2.setText(dbmc)
        cb3.setText(zbmc)
        cb4.setText(chmc)
    }

    Row{
        anchors.fill: parent
        spacing: 0*dp
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: parent.width*0.05
            Text{
                id: edit_name
                font.pixelSize: config.fontsize
                anchors.centerIn: parent
                text: xh
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: parent.width*0.16
            CustomInputText{
                id: edit_namev
                editWidth: parent.width
                anchors.verticalCenter: parent.verticalCenter
                defaultText: mc
                inputMaxLength: 20
                lengthVisible:false
                onTextChanged: {
                    infochange(1,edit_namev.getText())
                }
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: pbflag!==1?parent.width*0.14:parent.width*0.19
            CustomComboBox{
                id: cb1
                //            height: parent.height;
                editWidth: parent.width
                anchors.verticalCenter: parent.verticalCenter
                editDefaultText: fbmc
                model: mod11
                onCurrentText: {
                    infochange(2,cb1.getText())
                }
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: parent.width*0.02
            Text{
                font.pixelSize: config.fontsize
                anchors.centerIn: parent
                text: ">"
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: pbflag!==1?parent.width*0.14:parent.width*0.19
            CustomComboBox{
                id: cb2
                //            height: parent.height;
                editWidth: parent.width
                anchors.verticalCenter: parent.verticalCenter
                editDefaultText: dbmc
                model: mod12
                onCurrentText: {
                    infochange(3,cb2.getText())
                }
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: parent.width*0.02
            Text{
                font.pixelSize: config.fontsize
                anchors.centerIn: parent
                text: ">"
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            height: parent.height;
            width: pbflag!==1?parent.width*0.14:parent.width*0.19
            CustomComboBox{
                id: cb3
                //            height: parent.height;
                editWidth: parent.width
                anchors.verticalCenter: parent.verticalCenter
                editDefaultText: zbmc
                model: mod13
                onCurrentText: {
                    infochange(4,cb3.getText())
                }
            }
        }
        Item{visible: pbflag!==1; height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            visible: pbflag!==1
            height: parent.height;
            width: parent.width*0.02
            Text{
                font.pixelSize: config.fontsize
                anchors.centerIn: parent
                text: ">"
            }
        }
        Item{visible: pbflag!==1; height: parent.height; width: parent.width*0.01 } // 占位
        Rectangle{
            visible: pbflag!==1
            height: parent.height;
            width: parent.width*0.14
            CustomComboBox{
                id: cb4
                //            height: parent.height;
                editWidth: parent.width
                anchors.verticalCenter: parent.verticalCenter
                editDefaultText: chmc
                model: mod14
                onCurrentText: {
                    infochange(5,cb4.getText())
                }
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位
        // 操作
        Rectangle{
            height: parent.height;
            width: pbflag!==1?parent.width*0.06:parent.width*0.09
            Row{
                anchors.centerIn: parent
                spacing: 5*dp
                CustomButton{
                    width: 26*dp
                    height: 26*dp
                    icon_size: 23*dp
                    button_icon: "qrc:/picture/ph_del.png"
                    icon_color: "#999999"
                    icon_color_press: "#1677FF"
                    CustomTooltip{
                        visible: parent.isHovered
                        text: "删除"
                    }
                    CustomPopover{
                        posiX: parent.x-100*dp
                        title: "确认删除吗"
                        onAccepted: {
                            bt3()
                        }
                    }
                }
                CustomButton{
                    width: 26*dp
                    height: 26*dp
                    icon_size: 23*dp
                    button_icon: "qrc:/picture/pz_dc.png"
                    icon_color: "#999999"
                    icon_color_press: "#1677FF"
                    CustomTooltip{
                        visible: parent.isHovered
                        text: "导出"
                    }
                    onReleased: {
                        CExeConfig.exportMainExeConfig(xh)
                    }
                }
            }
        }
        Item{ height: parent.height; width: parent.width*0.01 } // 占位



    }
    Rectangle{
        x:0*dp
        y:parent.height-2*dp
        height: 2*dp
        width: parent.width
        color: "#DEDEDE"
    }



}
